package com.gitee.melin.bee.core.fs;

import com.gitee.melin.bee.core.fs.impl.AliyunOssFileSystem;
import com.gitee.melin.bee.core.fs.impl.AwsS3FileSystem;
import com.gitee.melin.bee.core.fs.impl.FtpFileSystem;
import com.gitee.melin.bee.core.fs.impl.HuaweiObsFileSystem;
import com.gitee.melin.bee.core.fs.impl.MinioFileSystem;
import com.gitee.melin.bee.core.fs.impl.TencentCosFileSystem;
import com.gitee.melin.bee.core.jdbc.enums.DataSourceType;

public class FileSystemFactory {

    private final AliyunOssFileSystem aliyunOssFileSystem;

    private final TencentCosFileSystem tencentCosFileSystem;

    private final HuaweiObsFileSystem huaweiObsFileSystem;

    private final AwsS3FileSystem awsS3FileSystem;

    private final MinioFileSystem minioFileSystem;

    private final FtpFileSystem ftpFileSystem;

    public FileSystemFactory(boolean supportAws) {
        this.aliyunOssFileSystem = new AliyunOssFileSystem();
        this.tencentCosFileSystem = new TencentCosFileSystem();
        this.huaweiObsFileSystem = new HuaweiObsFileSystem();
        if (supportAws) {
            this.awsS3FileSystem = new AwsS3FileSystem();
        } else {
            awsS3FileSystem = null;
        }
        this.minioFileSystem = new MinioFileSystem();
        this.ftpFileSystem = new FtpFileSystem();
    }

    public FileSystem getFileSystem(DataSourceType type) {
        switch (type) {
            case FTP:
                return ftpFileSystem;
            case MINIO:
                return minioFileSystem;
            case OSS:
                return aliyunOssFileSystem;
            case COS:
                return tencentCosFileSystem;
            case OBS:
                return huaweiObsFileSystem;
            case S3:
                return awsS3FileSystem;
            default:
                throw new RuntimeException("not support file system: " + type.getValue());
        }
    }
}
